﻿#region Librerias

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

#endregion


namespace ESF.General.GUI
{
	public class GUIHelper
	{
		public static void SetAdvance<W> (IProgressDialog<W> pProgressDialog, string pMessage = "", int pTotalWorkCount = 0, int pReadyWorkCount = 0, int pTotalErrors = 0, long pItemElapsedMs = 0)
		{
			double advance100;


			advance100 = ProcessHelper.GetAdvancePercentage100 (pTotalWorkCount, pReadyWorkCount + pTotalErrors);

			pProgressDialog.Title = "Procesando...";

			pProgressDialog.CurrentStepName = 
				(string.IsNullOrEmpty (pMessage) ? string.Empty : pMessage + "... ") + 
				string.Format ("Procesados {0} de {1}{3}: {2:0.##}%", pReadyWorkCount, pTotalWorkCount, advance100, 
				(pTotalErrors > 0 ? string.Format (" con {0} errores", pTotalErrors) : string.Empty));

			pProgressDialog.PercentageAdvance100 = advance100;

			if (advance100 == 100 && pProgressDialog.HideWhenComplete)
			{
				pProgressDialog.Hide ();
			}
		}
	}
}
